<?php

/*
 * This script belongs to Aspect PHP.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * This script is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
 * General Public License for more details.
 */

/**
 * aspectAutoloader is an autoloader for the Aspect PHP framework
 *
 * @package    aspectPhp
 * @subpackage lib
 * @author     gboisse
 */
class aspectAutoloader {

    /**
     * Registers myAspectAutoloader as an SPL autoloader
     */
    public static function register() {
        ini_set('unserialize_callback_func', 'spl_autoload_call');
        spl_autoload_register(array(new self, 'autoload'));
    }

    /**
     * Handles autoloading of classes
     *
     * @param  string $class  A class name
     * @return boolean Returns true if the class has been loaded
     */
    public function autoload($class) {
        if (0 !== strpos($class, 'aspect')) {
            return false;
        }

        require dirname(__FILE__) . '/' . $class . '.php';
        return true;
    }

}
